package org.mozhu.mboot.core.data;

import org.mozhu.mboot.core.data.filter.SearchFilter;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.NoRepositoryBean;

import java.io.Serializable;
import java.util.List;

@NoRepositoryBean
public interface BaseRepository<T, ID extends Serializable> extends JpaRepository<T, ID>, JpaSpecificationExecutor<T> {

	boolean support(String modelType);

	void deleteInBatch(final ID[] ids);

	List<T> findAll(List<SearchFilter> searchFilters);

	Page<T> findAll(List<SearchFilter> searchFilters, Pageable pageable);

	Page<T> findAll(SearchFilter searchFilter, Pageable pageable);

	List<T> findAll(SearchFilter searchFilter, Sort sort);

	List<T> findAll(List<SearchFilter> searchFilters, Sort sort);

	public Page<T> findAll(Searchable searchable);

	public long count(Searchable searchable);

	public <M> List<M> findAll(final String ql, final Object... params);

	public <M> Page<M> findAll(final Pageable pageable, final String ql, final Object... params);

	public <M> List<M> findAll(final Sort sort, final String ql, final Object... params);

	public <M> M findOne(final String ql, final Object... params);

	public long count(final String ql, final Object... params);

	public int batchUpdate(final String ql, final Object... params);
}
